# Maintainer: David Runge <dvzrv@archlinux.org>

_name=fastnumbers
pkgname=python-fastnumbers
pkgver=5.0.1
pkgrel=2
pkgdesc="Super-fast and clean conversions to numbers"
arch=(loong64 x86_64)
url="https://github.com/SethMMorton/fastnumbers"
license=(MIT)
depends=(python)
makedepends=(python-build python-installer python-setuptools python-wheel)
checkdepends=(python-hypothesis python-numpy python-pytest python-typing_extensions)
optdepends=(
  'python-numpy: for conversion to numpy arrays'
)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('fce2c2b71863d26bd8e93f11530a63f07ef00ea1006ea35c3d31091a352d72d4b97a3b358ba67f14522fd62e2a8e13ce3460ab3c75bbf950f664ab0eee1a7341')
b2sums=('ad7bcf62413399b1b90ece384215b1f7f19984af3b5cf6cad419052c5c76d211a2b28abcee5ffa3de57137c63f3494418589d55bd39f3037c931bde13ce02b90')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$site_packages:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
}
